var app = getApp();
Page({
  data: {
    /*页面配置 */
    winWidth: 0,
    winHeight: 0,
    // tab切换  
    userCellId: 0, 
    selected:true,
    apiurl: app.data.apiurl, 
    bid:'',
  },
  onLoad: function (options) {
    var that = this;
    wx.setNavigationBarTitle({
      title: '商城'
    })
  },
  onLoad: function () {
    var that = this;
    /** 获取系统信息 */
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          winWidth: res.windowWidth,
          winHeight: res.windowHeight
        });
      }
    });
    //商品品牌
    wx.request({
      url: getApp().data.apiurl + '/index.php/index/index/brand',
      data: {},
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        //品牌商品
        wx.request({
          url: getApp().data.apiurl + '/index.php/index/index/goods',
          data: { gbrand:res.data.data[0].bid },
          header: {
            'content-type': 'application/json'
          },
          success: function (res) {
            console.log(res);
            that.setData({
              goods: res.data
            });
          }
        })
        that.setData({
          brand: res.data,
          bid: res.data.data[0].bid
        });
      }
    })
  },
  /** 
     * 滑动切换tab 
     */
  bindChange: function (e) {
    var that = this;
    that.setData({ currentTab: e.detail.current });
  },
  /** 
   * 点击tab切换 
   */
  swichNav: function (e) {
    var that=this;
    this.setData({
      userCellId: e.target.dataset.idx,
      bid: e.target.dataset.bid,
    })
    //品牌商品
    wx.request({
      url: getApp().data.apiurl + '/index.php/index/index/goods',
      data: { gbrand: e.target.dataset.bid },
      header: {
        'content-type': 'application/json'
      },
      success: function (res) {
        that.setData({
          goods: res.data
        });
      }
    })

  },







})